package cn.java.web.side.transmittable;

import com.alibaba.ttl.TransmittableThreadLocal;
import org.omg.PortableInterceptor.INACTIVE;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class ThreadContext {

    private static final ThreadLocal<Integer> requesetContext =
            new TransmittableThreadLocal<>();


    public static void setUserId(Integer userId){

        System.out.println(Thread.currentThread().getName()+":"+Thread.currentThread().toString());
        requesetContext.set(userId);
        /*if(userContext == null){
            userContext = new HashMap<>();
            requesetContext.set(userContext);
        }
        userContext.put("USER_ID",userId);*/
    }

    public static Integer userId(){
        System.out.println(Thread.currentThread().getName()+":"+Thread.currentThread().toString());
        return requesetContext.get();
        /*if(stringObjectMap == null){
            return null;
        }
        return (Long)stringObjectMap.get("USER_ID");*/
    }

}
